home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / AIncludes / Threads.a < prev    next >
Encoding:
Text File  |  1996-05-01  |  8.9 KB  |  397 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Threads.a
  3. ;
  4. ;    Contains:    Thread Manager Interfaces.
  5. ;
  6. ;    Version:    Technology:    System 7.5
  7. ;                Release:    Universal Interfaces 3.0d3 on Copland DR1
  8. ;
  9. ;    Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10. ;
  11. ;    Bugs?:        If you find a problem with this file, send the file and version
  12. ;                information (from above) and the problem description to:
  13. ;
  14. ;                    Internet:    apple.bugs@applelink.apple.com
  15. ;                    AppleLink:    APPLE.BUGS
  16. ;
  17. ;
  18.     IF &TYPE('__THREADS__') = 'UNDEFINED' THEN
  19. __THREADS__ SET 1
  20.  
  21.     IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
  22.     include 'Errors.a'
  23.     ENDIF
  24.     IF &TYPE('__MEMORY__') = 'UNDEFINED' THEN
  25.     include 'Memory.a'
  26.     ENDIF
  27.     IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
  28. ;  Thread states 
  29. ; typedef unsigned short                 ThreadState
  30.  
  31.  
  32. kReadyThreadState                EQU        0
  33. kStoppedThreadState                EQU        1
  34. kRunningThreadState                EQU        2
  35. ;  Error codes have been meoved to Errors.(pah) 
  36. ;  Thread environment characteristics 
  37. ; typedef void *                        ThreadTaskRef
  38.  
  39. ;  Thread characteristics 
  40. ; typedef unsigned long                 ThreadStyle
  41.  
  42.  
  43. kCooperativeThread                EQU        $00000001
  44. kPreemptiveThread                EQU        $00000002
  45. ;  Thread identifiers 
  46. ; typedef unsigned long                 ThreadID
  47.  
  48.  
  49. kNoThreadID                        EQU        0
  50. kCurrentThreadID                EQU        1
  51. kApplicationThreadID            EQU        2
  52. ;  Options when creating a thread 
  53. ; typedef unsigned long                 ThreadOptions
  54.  
  55.  
  56. kNewSuspend                        EQU        $01
  57. kUsePremadeThread                EQU        $02
  58. kCreateIfNeeded                    EQU        $04
  59. kFPUNotNeeded                    EQU        $08
  60. kExactMatchThread                EQU        $10
  61. ;  Information supplied to the custom scheduler 
  62. SchedulerInfoRec        RECORD 0
  63. InfoRecSize                 ds.l    1                ; offset: $0 (0)
  64. CurrentThreadID             ds.l    1                ; offset: $4 (4)
  65. SuggestedThreadID         ds.l    1                ; offset: $8 (8)
  66. InterruptedCoopThreadID     ds.l    1                ; offset: $C (12)
  67. sizeof                     EQU *                    ; size:   $10 (16)
  68.                         ENDR
  69. ; typedef struct SchedulerInfoRec *        SchedulerInfoRecPtr
  70.  
  71.     IF GENERATING68K ** GENERATINGCFM THEN
  72. ;
  73. ;    The following UniversalProcPtrs are for CFM-68k compatiblity with
  74. ;    the implementation of the Thread Manager.
  75. ;
  76. ; typedef UniversalProcPtr                 ThreadEntryProcPtr
  77.  
  78. ; typedef UniversalProcPtr                 ThreadSchedulerProcPtr
  79.  
  80. ; typedef UniversalProcPtr                 ThreadSwitchProcPtr
  81.  
  82. ; typedef UniversalProcPtr                 ThreadTerminationProcPtr
  83.  
  84. ; typedef UniversalProcPtr                 DebuggerNewThreadProcPtr
  85.  
  86. ; typedef UniversalProcPtr                 DebuggerDisposeThreadProcPtr
  87.  
  88. ; typedef UniversalProcPtr                 DebuggerThreadSchedulerProcPtr
  89.  
  90.     ELSE
  91. ;
  92. ;    The following ProcPtrs cannot be interchanged with UniversalProcPtrs because
  93. ;    of differences between 680x0 and PowerPC runtime architectures with regard to
  94. ;    the implementation of the Thread Manager.
  95. ;
  96. ;  Prototype for thread's entry (main) routine 
  97. ; typedef void *                        voidPtr
  98.  
  99. ;  Prototype for custom thread scheduler routine 
  100. ;  Prototype for custom thread switcher routine 
  101. ;  Prototype for thread termination notification routine 
  102. ;  Prototype for debugger NewThread notification 
  103. ;  Prototype for debugger DisposeThread notification 
  104. ;  Prototype for debugger schedule notification 
  105.     ENDIF
  106. ;  Thread Manager routines 
  107. ;
  108. ; pascal OSErr CreateThreadPool(ThreadStyle threadStyle, short numToCreate, Size stackSize)
  109. ;
  110.     IF ¬ GENERATINGCFM THEN
  111.         Macro
  112.         _CreateThreadPool
  113.             move.w              #$0501,D0
  114.             dc.w                $ABF2
  115.         EndM
  116.     ELSE
  117.         IMPORT_CFM_FUNCTION CreateThreadPool
  118.     ENDIF
  119.  
  120. ;
  121. ; pascal OSErr GetFreeThreadCount(ThreadStyle threadStyle, short *freeCount)
  122. ;
  123.     IF ¬ GENERATINGCFM THEN
  124.         Macro
  125.         _GetFreeThreadCount
  126.             move.w              #$0402,D0
  127.             dc.w                $ABF2
  128.         EndM
  129.     ELSE
  130.         IMPORT_CFM_FUNCTION GetFreeThreadCount
  131.     ENDIF
  132.  
  133. ;
  134. ; pascal OSErr GetSpecificFreeThreadCount(ThreadStyle threadStyle, Size stackSize, short *freeCount)
  135. ;
  136.     IF ¬ GENERATINGCFM THEN
  137.         Macro
  138.         _GetSpecificFreeThreadCount
  139.             move.w              #$0615,D0
  140.             dc.w                $ABF2
  141.         EndM
  142.     ELSE
  143.         IMPORT_CFM_FUNCTION GetSpecificFreeThreadCount
  144.     ENDIF
  145.  
  146. ;
  147. ; pascal OSErr GetDefaultThreadStackSize(ThreadStyle threadStyle, Size *stackSize)
  148. ;
  149.     IF ¬ GENERATINGCFM THEN
  150.         Macro
  151.         _GetDefaultThreadStackSize
  152.             move.w              #$0413,D0
  153.             dc.w                $ABF2
  154.         EndM
  155.     ELSE
  156.         IMPORT_CFM_FUNCTION GetDefaultThreadStackSize
  157.     ENDIF
  158.  
  159. ;
  160. ; pascal OSErr ThreadCurrentStackSpace(ThreadID thread, unsigned long *freeStack)
  161. ;
  162.     IF ¬ GENERATINGCFM THEN
  163.         Macro
  164.         _ThreadCurrentStackSpace
  165.             move.w              #$0414,D0
  166.             dc.w                $ABF2
  167.         EndM
  168.     ELSE
  169.         IMPORT_CFM_FUNCTION ThreadCurrentStackSpace
  170.     ENDIF
  171.  
  172. ;
  173. ; pascal OSErr NewThread(ThreadStyle threadStyle, ThreadEntryProcPtr threadEntry, void *threadParam, Size stackSize, ThreadOptions options, void **threadResult, ThreadID *threadMade)
  174. ;
  175.     IF ¬ GENERATINGCFM THEN
  176.         Macro
  177.         _NewThread
  178.             move.w              #$0E03,D0
  179.             dc.w                $ABF2
  180.         EndM
  181.     ELSE
  182.         IMPORT_CFM_FUNCTION NewThread
  183.     ENDIF
  184.  
  185. ;
  186. ; pascal OSErr DisposeThread(ThreadID threadToDump, void *threadResult, Boolean recycleThread)
  187. ;
  188.     IF ¬ GENERATINGCFM THEN
  189.         Macro
  190.         _DisposeThread
  191.             move.w              #$0504,D0
  192.             dc.w                $ABF2
  193.         EndM
  194.     ELSE
  195.         IMPORT_CFM_FUNCTION DisposeThread
  196.     ENDIF
  197.  
  198. ;
  199. ; pascal OSErr YieldToThread(ThreadID suggestedThread)
  200. ;
  201.     IF ¬ GENERATINGCFM THEN
  202.         Macro
  203.         _YieldToThread
  204.             move.w              #$0205,D0
  205.             dc.w                $ABF2
  206.         EndM
  207.     ELSE
  208.         IMPORT_CFM_FUNCTION YieldToThread
  209.     ENDIF
  210.  
  211. ;
  212. ; pascal OSErr YieldToAnyThread(void )
  213. ;
  214.     IF ¬ GENERATINGCFM THEN
  215.         Macro
  216.         _YieldToAnyThread
  217.             clr.l               -(sp)
  218.             move.w              #$0205,D0
  219.             dc.w                $ABF2
  220.         EndM
  221.     ELSE
  222.         IMPORT_CFM_FUNCTION YieldToAnyThread
  223.     ENDIF
  224.  
  225. ;
  226. ; pascal OSErr GetCurrentThread(ThreadID *currentThreadID)
  227. ;
  228.     IF ¬ GENERATINGCFM THEN
  229.         Macro
  230.         _GetCurrentThread
  231.             move.w              #$0206,D0
  232.             dc.w                $ABF2
  233.         EndM
  234.     ELSE
  235.         IMPORT_CFM_FUNCTION GetCurrentThread
  236.     ENDIF
  237.  
  238. ;
  239. ; pascal OSErr GetThreadState(ThreadID threadToGet, ThreadState *threadState)
  240. ;
  241.     IF ¬ GENERATINGCFM THEN
  242.         Macro
  243.         _GetThreadState
  244.             move.w              #$0407,D0
  245.             dc.w                $ABF2
  246.         EndM
  247.     ELSE
  248.         IMPORT_CFM_FUNCTION GetThreadState
  249.     ENDIF
  250.  
  251. ;
  252. ; pascal OSErr SetThreadState(ThreadID threadToSet, ThreadState newState, ThreadID suggestedThread)
  253. ;
  254.     IF ¬ GENERATINGCFM THEN
  255.         Macro
  256.         _SetThreadState
  257.             move.w              #$0508,D0
  258.             dc.w                $ABF2
  259.         EndM
  260.     ELSE
  261.         IMPORT_CFM_FUNCTION SetThreadState
  262.     ENDIF
  263.  
  264. ;
  265. ; pascal OSErr SetThreadStateEndCritical(ThreadID threadToSet, ThreadState newState, ThreadID suggestedThread)
  266. ;
  267.     IF ¬ GENERATINGCFM THEN
  268.         Macro
  269.         _SetThreadStateEndCritical
  270.             move.w              #$0512,D0
  271.             dc.w                $ABF2
  272.         EndM
  273.     ELSE
  274.         IMPORT_CFM_FUNCTION SetThreadStateEndCritical
  275.     ENDIF
  276.  
  277. ;
  278. ; pascal OSErr SetThreadScheduler(ThreadSchedulerProcPtr threadScheduler)
  279. ;
  280.     IF ¬ GENERATINGCFM THEN
  281.         Macro
  282.         _SetThreadScheduler
  283.             move.w              #$0209,D0
  284.             dc.w                $ABF2
  285.         EndM
  286.     ELSE
  287.         IMPORT_CFM_FUNCTION SetThreadScheduler
  288.     ENDIF
  289.  
  290. ;
  291. ; pascal OSErr SetThreadSwitcher(ThreadID thread, ThreadSwitchProcPtr threadSwitcher, void *switchProcParam, Boolean inOrOut)
  292. ;
  293.     IF ¬ GENERATINGCFM THEN
  294.         Macro
  295.         _SetThreadSwitcher
  296.             move.w              #$070A,D0
  297.             dc.w                $ABF2
  298.         EndM
  299.     ELSE
  300.         IMPORT_CFM_FUNCTION SetThreadSwitcher
  301.     ENDIF
  302.  
  303. ;
  304. ; pascal OSErr SetThreadTerminator(ThreadID thread, ThreadTerminationProcPtr threadTerminator, void *terminationProcParam)
  305. ;
  306.     IF ¬ GENERATINGCFM THEN
  307.         Macro
  308.         _SetThreadTerminator
  309.             move.w              #$0611,D0
  310.             dc.w                $ABF2
  311.         EndM
  312.     ELSE
  313.         IMPORT_CFM_FUNCTION SetThreadTerminator
  314.     ENDIF
  315.  
  316. ;
  317. ; pascal OSErr ThreadBeginCritical(void )
  318. ;
  319.     IF ¬ GENERATINGCFM THEN
  320.         Macro
  321.         _ThreadBeginCritical
  322.             move.w              #$000B,D0
  323.             dc.w                $ABF2
  324.         EndM
  325.     ELSE
  326.         IMPORT_CFM_FUNCTION ThreadBeginCritical
  327.     ENDIF
  328.  
  329. ;
  330. ; pascal OSErr ThreadEndCritical(void )
  331. ;
  332.     IF ¬ GENERATINGCFM THEN
  333.         Macro
  334.         _ThreadEndCritical
  335.             move.w              #$000C,D0
  336.             dc.w                $ABF2
  337.         EndM
  338.     ELSE
  339.         IMPORT_CFM_FUNCTION ThreadEndCritical
  340.     ENDIF
  341.  
  342. ;
  343. ; pascal OSErr SetDebuggerNotificationProcs(DebuggerNewThreadProcPtr notifyNewThread, DebuggerDisposeThreadProcPtr notifyDisposeThread, DebuggerThreadSchedulerProcPtr notifyThreadScheduler)
  344. ;
  345.     IF ¬ GENERATINGCFM THEN
  346.         Macro
  347.         _SetDebuggerNotificationProcs
  348.             move.w              #$060D,D0
  349.             dc.w                $ABF2
  350.         EndM
  351.     ELSE
  352.         IMPORT_CFM_FUNCTION SetDebuggerNotificationProcs
  353.     ENDIF
  354.  
  355. ;
  356. ; pascal OSErr GetThreadCurrentTaskRef(ThreadTaskRef *threadTRef)
  357. ;
  358.     IF ¬ GENERATINGCFM THEN
  359.         Macro
  360.         _GetThreadCurrentTaskRef
  361.             move.w              #$020E,D0
  362.             dc.w                $ABF2
  363.         EndM
  364.     ELSE
  365.         IMPORT_CFM_FUNCTION GetThreadCurrentTaskRef
  366.     ENDIF
  367.  
  368. ;
  369. ; pascal OSErr GetThreadStateGivenTaskRef(ThreadTaskRef threadTRef, ThreadID threadToGet, ThreadState *threadState)
  370. ;
  371.     IF ¬ GENERATINGCFM THEN
  372.         Macro
  373.         _GetThreadStateGivenTaskRef
  374.             move.w              #$060F,D0
  375.             dc.w                $ABF2
  376.         EndM
  377.     ELSE
  378.         IMPORT_CFM_FUNCTION GetThreadStateGivenTaskRef
  379.     ENDIF
  380.  
  381. ;
  382. ; pascal OSErr SetThreadReadyGivenTaskRef(ThreadTaskRef threadTRef, ThreadID threadToSet)
  383. ;
  384.     IF ¬ GENERATINGCFM THEN
  385.         Macro
  386.         _SetThreadReadyGivenTaskRef
  387.             move.w              #$0410,D0
  388.             dc.w                $ABF2
  389.         EndM
  390.     ELSE
  391.         IMPORT_CFM_FUNCTION SetThreadReadyGivenTaskRef
  392.     ENDIF
  393.  
  394.     ENDIF
  395.     ENDIF ; __THREADS__ 
  396.  
  397.